package doantotnghiep.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@NamedNativeQueries(value = {@NamedNativeQuery(
	    name = "login",
	    query = "call login(:username,:pass);",
	    resultClass = Staff.class
	),
	@NamedNativeQuery(
		    name = "createAdmin",
		    query = "call createAdmin();",
		    resultClass = Staff.class
		)
})

@Table(name = "NhanVien")
public class Staff {

	private int id;
	private String fullName;
	private String address;
	private int sex;
	private String email;
	private String telNumber;
	private float income;
	private int status;
	private String birthDay;
	private String identifyNumber;
	private int isLogined;

	@Id
	@GeneratedValue
	@Column(name = "MaNV")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "HoTen")
	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	@Column(name = "DiaChi")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "GioiTinh")
	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	@Column(name = "Email")
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "DienThoai")
	public String getTelNumber() {
		return telNumber;
	}

	public void setTelNumber(String telNumber) {
		this.telNumber = telNumber;
	}

	@Column(name = "Luong")
	public float getIncome() {
		return income;
	}

	public void setIncome(float income) {
		this.income = income;
	}

	private Set<PurchaseOrder> purchaseOrders = new HashSet<PurchaseOrder>();

	@OneToMany(mappedBy = "staff", fetch = FetchType.LAZY)
	@Fetch(FetchMode.JOIN)
	public Set<PurchaseOrder> getPurchaseOrders() {
		return purchaseOrders;
	}

	public void setPurchaseOrders(Set<PurchaseOrder> purchaseOrders) {
		this.purchaseOrders = purchaseOrders;
	}

	private DivisionRoom divisionRoom;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MaPhongBan")
	@Fetch(FetchMode.JOIN)
	public DivisionRoom getDivisionRoom() {
		return divisionRoom;
	}

	public void setDivisionRoom(DivisionRoom divisionRoom) {
		this.divisionRoom = divisionRoom;
	}

	private Set<ImportedMedicament> importedMedicaments = new HashSet<ImportedMedicament>();

	@OneToMany(mappedBy = "staff", fetch = FetchType.LAZY)
	@Fetch(FetchMode.JOIN)
	public Set<ImportedMedicament> getImportedMedicaments() {
		return importedMedicaments;
	}

	public void setImportedMedicaments(
			Set<ImportedMedicament> importedMedicaments) {
		this.importedMedicaments = importedMedicaments;
	}

	private String userName;

	@Column(name = "TaiKhoan")
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	private String password;

	@Column(name = "MatKhau")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	private WorkPlayment position;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ChucVu")
	@Fetch(FetchMode.JOIN)
	public WorkPlayment getPosition() {
		return position;
	}

	public void setPosition(WorkPlayment position) {
		this.position = position;
	}

	@Column(name = "TrangThai")
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	@Column(name = "NgaySinh")
	public String getBirthDay() {
		return birthDay;
	}

	public void setBirthDay(String birthDay) {
		this.birthDay = birthDay;
	}

	@Column(name = "SoCMND")
	public String getIdentifyNumber() {
		return identifyNumber;
	}

	public void setIdentifyNumber(String identifyNumber) {
		this.identifyNumber = identifyNumber;
	}

	@Column(name = "DangNhap")
	public int getIsLogined() {
		return isLogined;
	}

	public void setIsLogined(int isLogined) {
		this.isLogined = isLogined;
	}

}
